<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
	<title>配送关系查看</title>
	<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
	 <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>配送关系查询</h1>
         <ol class="breadcrumb">
           <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">交易</a></li>
            <li class="active"><a href="#">配送关系</a></li>
            <li class="active"><a href="#">配送关系查询</a></li>
        </ol>
    </section>
    
    <section class="content">
       <form id="form" method="post" class="form-horizontal">
        <div class=" box box-success">
            <div class="box-body">
                
                <div class="input"  style="margin-top:-5px">
                       <div class="textalign1">医疗机构：</div>
                       <div class="boxinput">
                          <input type="text" class="textinput"  id="hospName" name="hospName"  placeholder="医疗机构" />
                       </div>
                       <div class="textalign">医疗机构地区：</div>
                       <div class="boxinput">
                       <table style="width:100%;">
                           <tr>
                              <td style="width:33%">
                                <select class="textinput" id="area1" name="area1" disabled="disabled">
                        <option value="${sysProvince }">${sysProvinceName }</option>
                        </select>
                              </td>
                              <td style="width:33%">   
                                <select class="textinput" id="area2" name="area2" ></select>
                                </td>
                              <td style="width:33%">
                                <select class="textinput" id="area3" name="area3" ></select>
                              </td>
                           </tr> 
                        </table>     
                       </div>
                       <div class="textalign">生产企业：</div>
                       <div class="boxinput">
                          <input type="text" class="textinput"  id="compName" name="compName" placeholder="生产企业" />
                       </div>
                       
                </div>
                <div class="input" >
                       <div class="textalign1">配送企业：</div>
                       <div class="boxinput">
                          <input type="text" class="textinput"  id="delCompName" name="delCompName" placeholder="配送企业"  />
                       </div>
                       <div class="textalign" >
                          <button type="button"  onclick="gridSerch()"  class="btn btn-success btn-sm" id="selectc">查&nbsp;询</button>
                       </div>
                </div>
            </div>
          </div>
        </form>
        <table class="jqgrid" id="gridlist"></table>
        <div id="prowed2"></div>
            
            <div class=" box box-warning bottongroup" id="bottongroup">
			<label onclick="removeDel();" class="btn btn-default btn-sm">解 除</label>
		</div>
</section>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">

//绑定回车
$('#goodsCode,#drugCode,#drugName,#compName,#area1,#area2,#area3,#delCompName,#projId').bind('keydown', function(event) {
    if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
        $('#selectc').click();
    }
}); 

$("#goodsCode").focus();//加载页面光标在第一个查询框上

function removeDel(){
    var rowIds = $("#gridlist").jqGrid("getGridParam", "selarrrow") || [];
	if (rowIds.length <= 0) {
		$.HN.message.alert("请选择要解除的配送企业！", "消息", "error");
		return;
	}
	$.HN.message.confirm("确定解除吗？", '', '').on(function (e) {
        if (e) {
	var param = "";
	for (var i=0; i<rowIds.length; i++) {
		rowId = rowIds[i];
		var rowdata = $("#gridlist").jqGrid('getRowData', rowId);
		param += rowId +",";
	}
	param = param.substring(0,param.length-1);
	$.post("${pageContext.request.contextPath}/baseGoods/removeDel.html", {
		"param":param,"status":"${status}"
		}, function(result) {
			if (result.success) {
				$.HN.message.alert("解除配送关系成功！", "消息", "success");
				//window.location.href="${ctx}/baseGoods/toProDelDrugList.html";
				gridSerch();
			} else {
				$.HN.message.alert("操作失败！", "消息", "error");
			}
		}, "json")
        }
	}); 
}
$(function () {
	$("#area2").HNSelect({
    	parent_selector: "#area1",  url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID",defaultText: "<option value=''>请选择</option>",
        func: function () {
            $("#area3").HNSelect({
                parent_selector: "#area2", url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID", defaultText: "<option value=''>请选择</option>",
                		
            });
        }
    });
	$("#projId").HNSelect({
        url: "${pageContext.request.contextPath}/selectController/getProj.html", data: { ID: '' },  defaultText: "<option value=''>请选择</option>",
    });
	
jQuery("#gridlist").jqGrid({
	url: "${ctx}/baseDel/getBaseDelCentreWithHospList.html",
    mtype: "POST",
	datatype: "json",
	autowidth: true,
//	height: 270,
	shrinkToFit:true,
   	colNames:['','配送区域','医疗机构','配送企业','生产企业'],
   	colModel:[
		{name:'del_rel_id',index:'del_rel_id',hidden:true, width:100, sorttype:"date"},
		{name:'area_name',index:'area_name', width:120,align:"center",  sortable:false},
		{name:'hosp_name',index:'hosp_name', width:120,align:"center",  sortable:false},
   		{name:'del_comp_name',index:'del_comp_name', width:190,  sortable:false},
   		{name:'prod_comp_name',index:'prod_comp_name', width:190,  sortable:false}
   		
   	],
	 rowNum: 20,
     rowList: [10, 20, 50,100],
     rownumbers: true,
     pager: "#prowed2",
     multiselect: true,
     viewrecords: true,
		gridComplete:function(){
         //序号列宽度自适应（参数为jqgridID）
         autoRNWidth("gridlist");
         //数据只有一条时默认选中（参数为jqgridID）
         selectByOneData("gridlist");
     }
     caption: "配送关系查询列表",
     jsonReader: {
         repeatitems: false,
         id: "del_rel_id"
     },
     
   	
});
	 
	jQuery("#gridlist").jqGrid('navGrid',"prowed2",{edit:false,add:false,del:false});
	$(window).trigger("resize");
	$("#gridlist").jqGrid("setGeidHeight", create());
});


function gridSerch() {
	var hospName = $.trim($("#hospName").val());
	var compName = $.trim($("#compName").val());
	var areaCode = $.trim($("#area3").val());
	var fatherCode = $.trim($("#area2").val());
	var delCompName = $.trim($("#delCompName").val());
	$("#gridlist").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{
        		"hospName":hospName,
        		"compName":compName,
        		"areaCode":areaCode,
        		"fatherCode":fatherCode,
        		"delCompName":delCompName}
    }).trigger("reloadGrid"); //重新载入  
}

	
</script>
</body>
</html>